# -*- coding: utf-8 -*-

# Define your item pipelines here
#
# Don't forget to add your pipeline to the ITEM_PIPELINES setting
# See: https://docs.scrapy.org/en/latest/topics/item-pipeline.html
import json
import codecs
import pandas as pd

class LianjiaPipeline(object):
    def __init__(self):
        self.file = codecs.open(filename='sss.csv', mode='w+', encoding='utf-8')

    def process_item(self, item, spider):
        data = pd.DataFrame(item)
        print(data)
        data.to_csv("链家北京主要房间历史数据.csv", mode='a', encoding='utf-8', header=False, index=False)

    def close_spider(self, spider):
        self.file.close()
